************************************************************************************************************************************************************************************************
*1. CONJOINT MODELS
************************************************************************************************************************************************************************************************

****TABLE 2 RESULTS****

*Select working directory
use "ConjointData.dta"

****************************************
*Perceived Leadership Abilities
****************************************

*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit leader obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit leader obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit leader obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Dem==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit leader obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)

****************************************
*Perceived Competence
****************************************

*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit competent obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit competent obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit competent obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Dem==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit competent obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)

****************************************
*Favorability (i.e., Feeling Thermometer
****************************************

*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit ft obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit ft obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit ft obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Dem==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit ft obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)

****************************************
*Job Approval
****************************************

*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit job obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit job obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit job obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Dem==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit job obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)

****************************************
*Rightness of Behavior
****************************************

*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit right obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit right obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit right obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Dem==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit right obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)

****************************************
*Perceived Effectiveness
****************************************

*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit effective obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit effective obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
*Republican Respondents - Without Controls for Racial Resentment and Sexism
fracreg logit effective obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive if Resp_Dem==1, vce(cluster responseid)
*Republican Respondents - With Controls for Racial Resentment and Sexism
fracreg logit effective obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)

clear


****GENERATING MARGINAL EFFECTS SHOWN IN FIGURE 2****

*See Code "Code_Figure2" to generate Figure 2

*****************************
*REPUBLICAN RESPONDENTS
*****************************

*Select working directory
use "ConjointData.dta"

matrix matreps=J(11, 12, .)
matrix matrepsmean=J(11, 6, .)

****************************************
*Perceived Leadership Abilities
****************************************

fracreg logit leader obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matrepsmean[1,1]=Coef[1,12]
matrix matrepsmean[2,1]=Coef[1,13]
matrix matrepsmean[3,1]=Coef[1,14]
matrix matrepsmean[4,1]=Coef[1,15]
matrix matrepsmean[5,1]=Coef[1,16]
matrix matrepsmean[6,1]=Coef[1,17]
matrix matrepsmean[7,1]=Coef[1,18]
matrix matrepsmean[8,1]=Coef[1,19]
matrix matrepsmean[9,1]=Coef[1,20]
matrix matrepsmean[10,1]=Coef[1,21]
matrix matrepsmean[11,1]=Coef[1,22]

*Low Bounds
matrix matreps[1,1]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,1]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,1]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,1]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,1]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,1]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,1]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,1]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,1]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,1]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,1]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matreps[1,2]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,2]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,2]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,2]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,2]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,2]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,2]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,2]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,2]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,2]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,2]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Perceived Competence
****************************************

fracreg logit competent obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matrepsmean[1,2]=Coef[1,12]
matrix matrepsmean[2,2]=Coef[1,13]
matrix matrepsmean[3,2]=Coef[1,14]
matrix matrepsmean[4,2]=Coef[1,15]
matrix matrepsmean[5,2]=Coef[1,16]
matrix matrepsmean[6,2]=Coef[1,17]
matrix matrepsmean[7,2]=Coef[1,18]
matrix matrepsmean[8,2]=Coef[1,19]
matrix matrepsmean[9,2]=Coef[1,20]
matrix matrepsmean[10,2]=Coef[1,21]
matrix matrepsmean[11,2]=Coef[1,22]

*Low Bounds
matrix matreps[1,3]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,3]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,3]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,3]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,3]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,3]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,3]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,3]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,3]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,3]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,3]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matreps[1,4]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,4]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,4]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,4]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,4]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,4]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,4]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,4]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,4]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,4]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,4]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Favorability (i.e., Feeling Thermometer
****************************************

fracreg logit ft obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matrepsmean[1,3]=Coef[1,12]
matrix matrepsmean[2,3]=Coef[1,13]
matrix matrepsmean[3,3]=Coef[1,14]
matrix matrepsmean[4,3]=Coef[1,15]
matrix matrepsmean[5,3]=Coef[1,16]
matrix matrepsmean[6,3]=Coef[1,17]
matrix matrepsmean[7,3]=Coef[1,18]
matrix matrepsmean[8,3]=Coef[1,19]
matrix matrepsmean[9,3]=Coef[1,20]
matrix matrepsmean[10,3]=Coef[1,21]
matrix matrepsmean[11,3]=Coef[1,22]

*Low Bounds
matrix matreps[1,5]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,5]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,5]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,5]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,5]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,5]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,5]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,5]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,5]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,5]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,5]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matreps[1,6]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,6]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,6]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,6]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,6]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,6]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,6]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,6]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,6]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,6]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,6]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Job Approval
****************************************

fracreg logit job obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matrepsmean[1,4]=Coef[1,12]
matrix matrepsmean[2,4]=Coef[1,13]
matrix matrepsmean[3,4]=Coef[1,14]
matrix matrepsmean[4,4]=Coef[1,15]
matrix matrepsmean[5,4]=Coef[1,16]
matrix matrepsmean[6,4]=Coef[1,17]
matrix matrepsmean[7,4]=Coef[1,18]
matrix matrepsmean[8,4]=Coef[1,19]
matrix matrepsmean[9,4]=Coef[1,20]
matrix matrepsmean[10,4]=Coef[1,21]
matrix matrepsmean[11,4]=Coef[1,22]

*Low Bounds
matrix matreps[1,7]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,7]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,7]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,7]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,7]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,7]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,7]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,7]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,7]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,7]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,7]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matreps[1,8]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,8]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,8]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,8]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,8]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,8]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,8]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,8]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,8]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,8]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,8]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Rightness of Behavior
****************************************

fracreg logit right obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matrepsmean[1,5]=Coef[1,12]
matrix matrepsmean[2,5]=Coef[1,13]
matrix matrepsmean[3,5]=Coef[1,14]
matrix matrepsmean[4,5]=Coef[1,15]
matrix matrepsmean[5,5]=Coef[1,16]
matrix matrepsmean[6,5]=Coef[1,17]
matrix matrepsmean[7,5]=Coef[1,18]
matrix matrepsmean[8,5]=Coef[1,19]
matrix matrepsmean[9,5]=Coef[1,20]
matrix matrepsmean[10,5]=Coef[1,21]
matrix matrepsmean[11,5]=Coef[1,22]

*Low Bounds
matrix matreps[1,9]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,9]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,9]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,9]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,9]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,9]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,9]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,9]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,9]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,9]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,9]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matreps[1,10]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,10]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,10]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,10]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,10]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,10]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,10]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,10]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,10]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,10]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,10]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Perceived Effectiveness
****************************************

fracreg logit effective obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matrepsmean[1,6]=Coef[1,12]
matrix matrepsmean[2,6]=Coef[1,13]
matrix matrepsmean[3,6]=Coef[1,14]
matrix matrepsmean[4,6]=Coef[1,15]
matrix matrepsmean[5,6]=Coef[1,16]
matrix matrepsmean[6,6]=Coef[1,17]
matrix matrepsmean[7,6]=Coef[1,18]
matrix matrepsmean[8,6]=Coef[1,19]
matrix matrepsmean[9,6]=Coef[1,20]
matrix matrepsmean[10,6]=Coef[1,21]
matrix matrepsmean[11,6]=Coef[1,22]

*Low Bounds
matrix matreps[1,11]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,11]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,11]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,11]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,11]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,11]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,11]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,11]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,11]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,11]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,11]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matreps[1,12]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,12]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,12]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,12]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,12]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,12]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,12]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,12]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,12]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,12]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,12]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

matlist matreps

matlist matrepsmean

*Store matrices

svmat double matreps
svmat double matrepsmean
keep matreps1-matrepsmean6
save "MarginalMatrix_Rep_95ciandMeans_DYDX.dta"

use "MarginalMatrix_Rep_95ciandMeans_DYDX.dta"
drop matrepsmean1-matrepsmean6
rename matreps1 RepLeaderLB
rename matreps2 RepLeaderUB
rename matreps3 RepCompetentLB
rename matreps4 RepCompetentUB
rename matreps5 RepftLB
rename matreps6 RepftUB
rename matreps7 RepJobLB
rename matreps8 RepJobUB
rename matreps9 RepRightLB
rename matreps10 RepRightUB
rename matreps11 RepEffectiveLB
rename matreps12 RepEffectiveUB
drop if RepLeaderLB==.
gen Obstruct=10*(_n-1)/100
move Obstruct RepLeaderLB
save "MarginalMatrix_Rep_95ci_DYDX.dta"

use "MarginalMatrix_Rep_95ciandMeans_DYDX.dta"
drop matreps1-matreps12
rename matrepsmean1 RepLeaderMean
rename matrepsmean2 RepCompetentMean
rename matrepsmean3 RepftMean
rename matrepsmean4 RepJobMean
rename matrepsmean5 RepRightMean
rename matrepsmean6 RepEffectiveMean
drop if RepLeaderMean==.
gen Obstruct=10*(_n-1)/100
move Obstruct RepLeaderMean
save "MarginalMatrix_Rep_Means_DYDX.dta"

clear


*****************************
*DEMOCRATIC RESPONDENTS
*****************************

*Select working directory
use "ConjointData.dta"

matrix matdems=J(11, 12, .)
matrix matdemsmean=J(11, 6, .)

****************************************
*Perceived Leadership Abilities
****************************************

fracreg logit leader obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matdemsmean[1,1]=Coef[1,12]
matrix matdemsmean[2,1]=Coef[1,13]
matrix matdemsmean[3,1]=Coef[1,14]
matrix matdemsmean[4,1]=Coef[1,15]
matrix matdemsmean[5,1]=Coef[1,16]
matrix matdemsmean[6,1]=Coef[1,17]
matrix matdemsmean[7,1]=Coef[1,18]
matrix matdemsmean[8,1]=Coef[1,19]
matrix matdemsmean[9,1]=Coef[1,20]
matrix matdemsmean[10,1]=Coef[1,21]
matrix matdemsmean[11,1]=Coef[1,22]

*Low Bounds
matrix matdems[1,1]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,1]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,1]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,1]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,1]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,1]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,1]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,1]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,1]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,1]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,1]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matdems[1,2]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,2]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,2]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,2]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,2]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,2]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,2]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,2]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,2]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,2]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,2]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Perceived Competence
****************************************

fracreg logit competent obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matdemsmean[1,2]=Coef[1,12]
matrix matdemsmean[2,2]=Coef[1,13]
matrix matdemsmean[3,2]=Coef[1,14]
matrix matdemsmean[4,2]=Coef[1,15]
matrix matdemsmean[5,2]=Coef[1,16]
matrix matdemsmean[6,2]=Coef[1,17]
matrix matdemsmean[7,2]=Coef[1,18]
matrix matdemsmean[8,2]=Coef[1,19]
matrix matdemsmean[9,2]=Coef[1,20]
matrix matdemsmean[10,2]=Coef[1,21]
matrix matdemsmean[11,2]=Coef[1,22]

*Low Bounds
matrix matdems[1,3]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,3]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,3]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,3]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,3]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,3]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,3]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,3]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,3]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,3]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,3]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matdems[1,4]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,4]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,4]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,4]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,4]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,4]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,4]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,4]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,4]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,4]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,4]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Favorability (i.e., Feeling Thermometer
****************************************

fracreg logit ft obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matdemsmean[1,3]=Coef[1,12]
matrix matdemsmean[2,3]=Coef[1,13]
matrix matdemsmean[3,3]=Coef[1,14]
matrix matdemsmean[4,3]=Coef[1,15]
matrix matdemsmean[5,3]=Coef[1,16]
matrix matdemsmean[6,3]=Coef[1,17]
matrix matdemsmean[7,3]=Coef[1,18]
matrix matdemsmean[8,3]=Coef[1,19]
matrix matdemsmean[9,3]=Coef[1,20]
matrix matdemsmean[10,3]=Coef[1,21]
matrix matdemsmean[11,3]=Coef[1,22]

*Low Bounds
matrix matdems[1,5]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,5]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,5]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,5]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,5]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,5]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,5]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,5]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,5]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,5]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,5]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matdems[1,6]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,6]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,6]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,6]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,6]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,6]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,6]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,6]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,6]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,6]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,6]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Job Approval
****************************************

fracreg logit job obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matdemsmean[1,4]=Coef[1,12]
matrix matdemsmean[2,4]=Coef[1,13]
matrix matdemsmean[3,4]=Coef[1,14]
matrix matdemsmean[4,4]=Coef[1,15]
matrix matdemsmean[5,4]=Coef[1,16]
matrix matdemsmean[6,4]=Coef[1,17]
matrix matdemsmean[7,4]=Coef[1,18]
matrix matdemsmean[8,4]=Coef[1,19]
matrix matdemsmean[9,4]=Coef[1,20]
matrix matdemsmean[10,4]=Coef[1,21]
matrix matdemsmean[11,4]=Coef[1,22]

*Low Bounds
matrix matdems[1,7]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,7]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,7]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,7]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,7]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,7]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,7]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,7]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,7]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,7]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,7]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matdems[1,8]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,8]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,8]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,8]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,8]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,8]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,8]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,8]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,8]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,8]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,8]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Rightness of Behavior
****************************************

fracreg logit right obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matdemsmean[1,5]=Coef[1,12]
matrix matdemsmean[2,5]=Coef[1,13]
matrix matdemsmean[3,5]=Coef[1,14]
matrix matdemsmean[4,5]=Coef[1,15]
matrix matdemsmean[5,5]=Coef[1,16]
matrix matdemsmean[6,5]=Coef[1,17]
matrix matdemsmean[7,5]=Coef[1,18]
matrix matdemsmean[8,5]=Coef[1,19]
matrix matdemsmean[9,5]=Coef[1,20]
matrix matdemsmean[10,5]=Coef[1,21]
matrix matdemsmean[11,5]=Coef[1,22]

*Low Bounds
matrix matdems[1,9]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,9]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,9]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,9]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,9]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,9]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,9]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,9]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,9]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,9]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,9]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matdems[1,10]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,10]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,10]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,10]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,10]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,10]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,10]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,10]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,10]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,10]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,10]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

****************************************
*Perceived Effectiveness
****************************************

fracreg logit effective obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matdemsmean[1,6]=Coef[1,12]
matrix matdemsmean[2,6]=Coef[1,13]
matrix matdemsmean[3,6]=Coef[1,14]
matrix matdemsmean[4,6]=Coef[1,15]
matrix matdemsmean[5,6]=Coef[1,16]
matrix matdemsmean[6,6]=Coef[1,17]
matrix matdemsmean[7,6]=Coef[1,18]
matrix matdemsmean[8,6]=Coef[1,19]
matrix matdemsmean[9,6]=Coef[1,20]
matrix matdemsmean[10,6]=Coef[1,21]
matrix matdemsmean[11,6]=Coef[1,22]

*Low Bounds
matrix matdems[1,11]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,11]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,11]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,11]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,11]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,11]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,11]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,11]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,11]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,11]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,11]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matdems[1,12]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,12]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,12]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,12]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,12]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,12]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,12]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,12]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,12]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,12]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,12]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

matlist matdems

matlist matdemsmean

*Store matrices

svmat double matdems
svmat double matdemsmean
keep matdems1-matdemsmean6
save "MarginalMatrix_Dem_95ciandMeans_DYDX.dta"

use "MarginalMatrix_Dem_95ciandMeans_DYDX.dta"
drop matdemsmean1-matdemsmean6
rename matdems1 DemLeaderLB
rename matdems2 DemLeaderUB
rename matdems3 DemCompetentLB
rename matdems4 DemCompetentUB
rename matdems5 DemftLB
rename matdems6 DemftUB
rename matdems7 DemJobLB
rename matdems8 DemJobUB
rename matdems9 DemRightLB
rename matdems10 DemRightUB
rename matdems11 DemEffectiveLB
rename matdems12 DemEffectiveUB
drop if DemLeaderLB==.
gen Obstruct=10*(_n-1)/100
move Obstruct DemLeaderLB
save "MarginalMatrix_Dem_95ci_DYDX.dta"

use "MarginalMatrix_Dem_95ciandMeans_DYDX.dta"
drop matdems1-matdems12
rename matdemsmean1 DemLeaderMean
rename matdemsmean2 DemCompetentMean
rename matdemsmean3 DemftMean
rename matdemsmean4 DemJobMean
rename matdemsmean5 DemRightMean
rename matdemsmean6 DemEffectiveMean
drop if DemLeaderMean==.
gen Obstruct=10*(_n-1)/100
move Obstruct DemLeaderMean
save "MarginalMatrix_Dem_Means_DYDX.dta"

clear


****GENERATING MARGINAL EFFECTS SHOWN IN FIGURE 3****

*See Code "Code_Figure3" to generate Figure 3

*****************************
*REPUBLICAN RESPONDENTS
*****************************

*Select working directory
use "ConjointData.dta"

pca leader competent ft job right effective
predict pc1
sum pc1
scalar pc1min=r(min)
scalar pc1max=r(max)

*Any variable v with observed min and max values can be rescaled to range min' to max' by formula (max'-min')/(max-min)*(v-max)+max'

gen pc1_rescale=1/(pc1max-pc1min)*(pc1-pc1max)+1

matrix matreps=J(11, 2, .)
matrix matrepsmean=J(11, 1, .)

fracreg logit pc1_rescale obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Rep==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matrepsmean[1,1]=Coef[1,12]
matrix matrepsmean[2,1]=Coef[1,13]
matrix matrepsmean[3,1]=Coef[1,14]
matrix matrepsmean[4,1]=Coef[1,15]
matrix matrepsmean[5,1]=Coef[1,16]
matrix matrepsmean[6,1]=Coef[1,17]
matrix matrepsmean[7,1]=Coef[1,18]
matrix matrepsmean[8,1]=Coef[1,19]
matrix matrepsmean[9,1]=Coef[1,20]
matrix matrepsmean[10,1]=Coef[1,21]
matrix matrepsmean[11,1]=Coef[1,22]

*Low Bounds
matrix matreps[1,1]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,1]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,1]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,1]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,1]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,1]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,1]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,1]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,1]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,1]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,1]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matreps[1,2]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matreps[2,2]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matreps[3,2]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matreps[4,2]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matreps[5,2]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matreps[6,2]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matreps[7,2]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matreps[8,2]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matreps[9,2]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matreps[10,2]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matreps[11,2]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

matlist matreps
matlist matrepsmean

*Store matrices

svmat double matreps
svmat double matrepsmean
keep matreps1-matrepsmean1
save "MarginalMatrix_Rep_CompositeMeans_DYDX.dta"

use "MarginalMatrix_Rep_CompositeMeans_DYDX.dta"
drop matrepsmean1
rename matreps1 RepCompositeLB
rename matreps2 RepCompostieUB
drop if RepCompositeLB==.
gen Obstruct=10*(_n-1)/100
move Obstruct RepCompositeLB
save "MarginalMatrix_Rep_Composite95CI_DYDX.dta"

use "MarginalMatrix_Rep_CompositeMeans_DYDX.dta"
drop matreps1-matreps2
rename matrepsmean1 RepCompositeMean
drop if RepCompositeMean==.
gen Obstruct=10*(_n-1)/100
move Obstruct RepCompositeMean
save "MarginalMatrix_Rep_CompositeMeans_DYDX.dta", replace

clear

*****************************
*DEMOCRATIC RESPONDENTS
*****************************

*Select working directory
use "ConjointData.dta"

pca leader competent ft job right effective
predict pc1
sum pc1
scalar pc1min=r(min)
scalar pc1max=r(max)

*Any variable v with observed min and max values can be rescaled to range min' to max' by formula (max'-min')/(max-min)*(v-max)+max'

gen pc1_rescale=1/(pc1max-pc1min)*(pc1-pc1max)+1

matrix matdems=J(11, 2, .)
matrix matdemsmean=J(11, 1, .)

fracreg logit pc1_rescale obstructive i.Resp_Gender##c.obstructive i.Resp_Race##c.obstructive i.Resp_Age##c.obstructive i.Resp_Educ##c.obstructive i.Resp_InterestCat##c.obstructive i.Resp_MediaConsCat##c.obstructive i.Resp_Urban##c.obstructive i.knowscale##c.obstructive i.Obstructed_Party##c.obstructive i.Leg_Party##c.obstructive i.Leg_Gender##c.obstructive i.Leg_Race##c.obstructive i.Leg_Ideology##c.obstructive i.Bill_Topic##c.obstructive c.Resp_hsscale##c.obstructive c.Resp_bsscale##c.obstructive c.Resp_rrscale##c.obstructive if Resp_Dem==1, vce(cluster responseid)
margins, dydx(Leg_Gender) at(obstructive=(0(.1)1)) atmeans post
eststo m1
matrix Coef=e(b)
matrix V=e(V)

*Means
matrix matdemsmean[1,1]=Coef[1,12]
matrix matdemsmean[2,1]=Coef[1,13]
matrix matdemsmean[3,1]=Coef[1,14]
matrix matdemsmean[4,1]=Coef[1,15]
matrix matdemsmean[5,1]=Coef[1,16]
matrix matdemsmean[6,1]=Coef[1,17]
matrix matdemsmean[7,1]=Coef[1,18]
matrix matdemsmean[8,1]=Coef[1,19]
matrix matdemsmean[9,1]=Coef[1,20]
matrix matdemsmean[10,1]=Coef[1,21]
matrix matdemsmean[11,1]=Coef[1,22]

*Low Bounds
matrix matdems[1,1]=Coef[1,12]-sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,1]=Coef[1,13]-sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,1]=Coef[1,14]-sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,1]=Coef[1,15]-sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,1]=Coef[1,16]-sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,1]=Coef[1,17]-sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,1]=Coef[1,18]-sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,1]=Coef[1,19]-sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,1]=Coef[1,20]-sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,1]=Coef[1,21]-sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,1]=Coef[1,22]-sqrt(V[22,22])*invnormal(0.975)

*Upper Bounds
matrix matdems[1,2]=Coef[1,12]+sqrt(V[12,12])*invnormal(0.975)
matrix matdems[2,2]=Coef[1,13]+sqrt(V[13,13])*invnormal(0.975)
matrix matdems[3,2]=Coef[1,14]+sqrt(V[14,14])*invnormal(0.975)
matrix matdems[4,2]=Coef[1,15]+sqrt(V[15,15])*invnormal(0.975)
matrix matdems[5,2]=Coef[1,16]+sqrt(V[16,16])*invnormal(0.975)
matrix matdems[6,2]=Coef[1,17]+sqrt(V[17,17])*invnormal(0.975)
matrix matdems[7,2]=Coef[1,18]+sqrt(V[18,18])*invnormal(0.975)
matrix matdems[8,2]=Coef[1,19]+sqrt(V[19,19])*invnormal(0.975)
matrix matdems[9,2]=Coef[1,20]+sqrt(V[20,20])*invnormal(0.975)
matrix matdems[10,2]=Coef[1,21]+sqrt(V[21,21])*invnormal(0.975)
matrix matdems[11,2]=Coef[1,22]+sqrt(V[22,22])*invnormal(0.975)

matlist matdems
matlist matdemsmean

*Store matrices

svmat double matdems
svmat double matdemsmean
keep matdems1-matdemsmean1
save "MarginalMatrix_Dem_CompositeMeans_DYDX.dta"

use "MarginalMatrix_Dem_CompositeMeans_DYDX.dta"
drop matdemsmean1
rename matdems1 DemCompositeLB
rename matdems2 DemCompostieUB
drop if DemCompositeLB==.
gen Obstruct=10*(_n-1)/100
move Obstruct DemCompositeLB
save "MarginalMatrix_Dem_Composite95CI_DYDX.dta"

use "MarginalMatrix_Dem_CompositeMeans_DYDX.dta"
drop matdems1-matdems2
rename matdemsmean1 DemCompositeMean
drop if DemCompositeMean==.
gen Obstruct=10*(_n-1)/100
move Obstruct DemCompositeMean
save "MarginalMatrix_Dem_CompositeMeans_DYDX.dta", replace

clear



************************************************************************************************************************************************************************************************
*2. OBSERVATIONAL MODELS
************************************************************************************************************************************************************************************************

****RESULTS OF OBSERVATIONAL MODELS PRESENTED IN SECTION V OF SUPPLEMENTAL APPENDIX****

*Select working directory
use "ENewsletterData.dta"

*Column 1
logit obstruction_dich woman document_hostile meddist black latino Leader vote_pct seniority lesclassic i.congress i.House i.majority if party_code==200, vce(cluster icpsr)
*Column 2
logit obstruction_dich woman document_hostile meddist black latino Leader vote_pct seniority lesclassic PercUnemployed MedianHouseholdIncome PercFemale AgeMedian PercBlack PercHispanicAnyRace PercBachAndAbove i.congress i.House i.majority if party_code==200, vce(cluster icpsr)
*Column 3
logit obstruction_dich woman document_hostile meddist black latino Leader vote_pct seniority lesclassic i.congress i.House i.majority if party_code==100, vce(cluster icpsr)
*Column 4
logit obstruction_dich woman document_hostile meddist black latino Leader vote_pct seniority lesclassic PercUnemployed MedianHouseholdIncome PercFemale AgeMedian PercBlack PercHispanicAnyRace PercBachAndAbove i.congress i.House i.majority if party_code==100, vce(cluster icpsr)

clear

****GENERATING PREDICTIONS FOR FIGURE 4****

*Note that there will be trivial variation in predictions across successive simulations

*****************************
*REPUBLICAN RESPONDENTS
*****************************

*Select working directory
use "ENewsletterData.dta"

set seed 1234

tab congress, gen(cong)

*Model with complete complement of covariates
estsimp logit obstruction_dich woman document_hostile meddist black latino Leader vote_pct seniority lesclassic PercUnemployed MedianHouseholdIncome PercFemale AgeMedian PercBlack PercHispanicAnyRace PercBachAndAbove cong2 cong3 cong4 cong5 cong6 House majority if party_code==200, vce(cluster icpsr) sims(10000)
setx mean
simqi, fd(prval(1)) changex(woman 0 1)

*      Quantity of Interest |     Mean       Std. Err.    [95% Conf. Interval]
*---------------------------+--------------------------------------------------
*         dPr(obstru~h = 1) |   .0097196     .0045447     .0010556    .0191396

setx mean
setx woman 1
simqi, prval(1) genpr(RepWomanPR)
setx mean
setx woman 0
simqi, prval(1) genpr(RepManPR)
gen RepPrDiff=RepWomanPR-RepManPR
sum RepPrDiff
egen RepPrDiffSort=clsort(RepPrDiff)
gen iter=_n
keep RepWomanPR-iter
move iter RepWomanPR
list RepPrDiffSort if iter==250
list RepPrDiffSort if iter==9750

egen RepWomanPRSort=clsort(RepWomanPR)
sum RepWomanPRSort
*Mean=.0521832
list RepWomanPRSort if iter==825
*LB=.0464793
list RepWomanPRSort if iter==9175
*UB=.0582808 

egen RepManPRSort=clsort(RepManPR)
sum RepManPRSort
*Mean=.0424636
list RepManPRSort if iter==825
*LB=.039708
list RepManPRSort if iter==9175
*UB=.0453422
save "Preds_RepObstrProb.dta"

clear

*****************************
*DEMOCRATIC RESPONDENTS
*****************************

*Select working directory
use "ENewsletterData.dta"

set seed 1234

tab congress, gen(cong)

*Model with complete complement of covariates
estsimp logit obstruction_dich woman document_hostile meddist black latino Leader vote_pct seniority lesclassic PercUnemployed MedianHouseholdIncome PercFemale AgeMedian PercBlack PercHispanicAnyRace PercBachAndAbove cong2 cong3 cong4 cong5 cong6 House majority if party_code==100, vce(cluster icpsr) sims(10000)
setx mean
simqi, fd(prval(1)) changex(woman 0 1)

*      Quantity of Interest |     Mean       Std. Err.    [95% Conf. Interval]
*---------------------------+--------------------------------------------------
*         dPr(obstru~h = 1) |  -.0012484     .0030016     -.007032     .004918

setx mean
setx woman 1
simqi, prval(1) genpr(DemWomanPR)
setx mean
setx woman 0
simqi, prval(1) genpr(DemManPR)
gen DemPrDiff=DemWomanPR-DemManPR
sum DemPrDiff
egen DemPrDiffSort=clsort(DemPrDiff)
gen iter=_n
keep DemWomanPR-iter
move iter DemWomanPR
list DemPrDiffSort if iter==250
list DemPrDiffSort if iter==9750

egen DemWomanPRSort=clsort(DemWomanPR)
sum DemWomanPRSort
*Mean=.0238783
list DemWomanPRSort if iter==825
*LB=.0205211
list DemWomanPRSort if iter==9175
*UB=.0274973  

egen DemManPRSort=clsort(DemManPR)
sum DemManPRSort
*Mean=.0251267
list DemManPRSort if iter==825
*LB=.022504
list DemManPRSort if iter==9175
*UB=.027899 
save "Preds_DemObstrProb.dta"

clear


****Constructing Datasets for Figure 4****

*Predicted Probability Figure (Figure 4[a])

use "Preds_RepObstrProb.dta"
sum RepWomanPRSort
*Mean=.0521832
list RepWomanPRSort if iter==825
*LB=.0464793
list RepWomanPRSort if iter==9175
*UB=.0582808
sum RepManPRSort
*Mean=.0424636
list RepManPRSort if iter==825
*LB=.039708 
list RepManPRSort if iter==9175
*UB=.0453422

clear

use "Preds_DemObstrProb.dta"
sum DemWomanPRSort
*Mean=.0238783
list DemWomanPRSort if iter==825
*LB=.0205211 
list DemWomanPRSort if iter==9175
*UB=.0274973
sum DemManPRSort
*Mean=.0251267
list DemManPRSort if iter==825
*LB=.022504
list DemManPRSort if iter==9175
*UB=.027899  

clear

set obs 4
gen Scale=5-_n
gen Mean=_n
gen LB=_n
gen UB=_n

gen Party="Republicans" if Scale>=3
replace Party="Democrats" if Scale<=2
gen Gender="Women" if Scale==2 | Scale==4
replace Gender="Men" if Scale==1 | Scale==3
replace Mean=.0521832 if Scale==4
replace Mean=.0424636 if Scale==3
replace Mean=.0238783 if Scale==2
replace Mean=.0251267 if Scale==1
replace LB=.0464793 if Scale==4
replace LB=.039708 if Scale==3
replace LB=.0205211 if Scale==2
replace LB=.022504 if Scale==1
replace UB=.0582808 if Scale==4
replace UB=.0453422 if Scale==3
replace UB=.0274973 if Scale==2
replace UB=.027899 if Scale==1

save "Preds_ObstrProbPredsFigure.dta"

use "Preds_ObstrProbPredsFigure.dta"

gsort -Gender -Scale

gen Scale_01=.
gen Mean_01=.
gen LB_01=.
gen UB_01=.
gen Party_01=" "
gen Gender_01="Men"

replace Scale_01=3 if Scale==4
replace Scale_01=1 if Scale==2
replace Mean_01=.0424586 if Scale_01==3
replace Mean_01=.0251493 if Scale_01==1
replace LB_01=.0396938 if Scale_01==3
replace LB_01=.0224869 if Scale_01==1
replace UB_01=.0453429 if Scale_01==3
replace UB_01=.0279801 if Scale_01==1
replace Party_01="Republicans" if Scale_01==3
replace Party_01="Democrats" if Scale_01==1
drop if Scale_01==.

save "Preds_ObstrProbPredsFigure_Reshape.dta"

clear

*Marginal Effects Figure (Figure 4[b])

use "Preds_RepObstrProb.dta"
sum RepPrDiffSort
*Mean=.0097196
list RepPrDiffSort if iter==250
*LB=.0010425 
list RepPrDiffSort if iter==9750
*UB=.0191339

use "Preds_DemObstrProb.dta"
sum DemPrDiffSort
*Mean=-.0012484
list DemPrDiffSort if iter==250
*LB=-.007032 
list DemPrDiffSort if iter==9750
*UB=.0049156

clear

set obs 2
gen Scale=3-_n
gen Mean=_n
gen LB=_n
gen UB=_n

gen Party="Republicans" if Scale==2
replace Party="Democrats" if Scale==1
replace Mean=.0097196 if Scale==2
replace Mean=-.0012484 if Scale==1
replace LB=.0010425 if Scale==2
replace LB=-.007032 if Scale==1
replace UB=.0191339 if Scale==2
replace UB=.0049156 if Scale==1

save "Preds_ObstrProbMargEffsFigure.dta"
